Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Javascript adding custom meta tags, css and/or scripts to the head or before the </body> tag

I have a react/redux page that makes a call to an API that in the response that can return things that will need to be added to either before the </head>(head) or before the </body> (footer). They can be custom meta tags, css and/or scripts. I tried doing window.document.head.appendChild but that only works on nodes and I have to create the element.

The response should come back in the correct format so for example

<meta name=test123> <script type=text/javascript src=test123></script>

I tried doing window.document.head.innerHTML = <script ...> which appends it to the top but then it messes up all of the styling for some reason. When I did window.document.head.innerHTML += <script ...> it caused lots of repeats.

So I was wondering what's the best way to do this because from the googling I've done I've only seen the appendChild mentioned most of the time.

Also what would the best way to append it to before the </body>(footer) tag?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!